//
//  MediaCell.m
//  YongChuanTradingArea
//
//  Created by Vivian on 2017/9/13.
//  Copyright © 2017年 李冰. All rights reserved.
//

#import "MediaCell.h"

@interface MediaCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImgView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subtitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@end

@implementation MediaCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.iconImgView.layer.masksToBounds = YES;
    self.iconImgView.layer.cornerRadius = 22;
    // Initialization code
}

- (void)setModel:(MineMediaModel *)model{
    _model = model;
    for (MineMediaModelImgList *img in _model.ImgList) {
        if ([img.imgtype isEqualToString:@"TXTP"]) {
            [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:img.image] placeholderImage:PLACE_HOLDER];
        }
    }
    if ([_model.MEMBERNAME isTelephoneNumber]) {
        self.titleLabel.text = [_model.MEMBERNAME stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    }else{
        self.titleLabel.text = _model.MEMBERNAME;
    }
    self.countLabel.text = _model.TOTALSCORE;
    self.timeLabel.text = [NSDate timeStringWithTimestamp:[_model.UPDATETIME getTimestamp] formatterString:@"yyyy-MM-dd"];;
    switch ([_model.USERTYPE integerValue]) {
        case 1:
        {
            self.subtitleLabel.text = @"消费股东";
        }
            break;
        case 2:
        {
            self.subtitleLabel.text = @"会员店";
        }
            break;
        case 3:
        {
            self.subtitleLabel.text = @"企业合伙人";
        }
            break;
        case 4:
        {
            self.subtitleLabel.text = @"个人合伙人";
        }
            break;
        default:
            break;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
